package org.edu.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

@Entity
@Proxy(lazy = false)
@Table(name = "STUDENTPROJECT", catalog = "SCHOOL")
public class StudentProject implements Serializable {

	private static final long serialVersionUID = 1L;
	private Long student_project_id;
	private Student student;
	private TeacherProject teacherProject;
	private Notesp notesp;

	@Id
	@GeneratedValue
	@Column(name = "STUDENT_PROJECT_ID")
	public Long getStudent_project_id() {
		return student_project_id;
	}

	public void setStudent_project_id(Long student_project_id) {
		this.student_project_id = student_project_id;
	}

	@ManyToOne
	@JoinColumn(name = "STUDENT_ID")
	public Student getStudent() {
		return student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	@ManyToOne
	@JoinColumn(name = "TEACHER_ID")
	public TeacherProject getTeacherProject() {
		return teacherProject;
	}

	public void setTeacherProject(TeacherProject teacherProject) {
		this.teacherProject = teacherProject;
	}

	@OneToOne(mappedBy = "studentProject", cascade = CascadeType.ALL)
	public Notesp getNotesp() {
		return notesp;
	}

	public void setNotesp(Notesp notesp) {
		this.notesp = notesp;
	}

	public StudentProject() {
		super();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((notesp == null) ? 0 : notesp.hashCode());
		result = prime * result + ((student == null) ? 0 : student.hashCode());
		result = prime
				* result
				+ ((student_project_id == null) ? 0 : student_project_id
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		StudentProject other = (StudentProject) obj;
		if (notesp == null) {
			if (other.notesp != null)
				return false;
		} else if (!notesp.equals(other.notesp))
			return false;
		if (student == null) {
			if (other.student != null)
				return false;
		} else if (!student.equals(other.student))
			return false;
		if (student_project_id == null) {
			if (other.student_project_id != null)
				return false;
		} else if (!student_project_id.equals(other.student_project_id))
			return false;
		return true;
	}
	
}
